#!/usr/bin/env python3

'''
The first two consecutive numbers to have two distinct prime factors are:

14 = 2 × 7
15 = 3 × 5

The first three consecutive numbers to have three distinct prime factors are:

644 = 2² × 7 × 23
645 = 3 × 5 × 43
646 = 2 × 17 × 19.

Find the first four consecutive integers to have four distinct prime factors. What is the first of these numbers?
'''


from euler import getprimes

primes = getprimes(10000)


# NEED TO TRY USING A SEIVE TO WEED OUT THOSE WITH > 4 prime or < 4 prime
def getfactors(num):
    for x in range(2,num):
        if num % x == 0:
            yield x

x = 2
test = 0
while True:
    ftest = 0
    for factor in getfactors(x):
        if factor in primes:
            ftest += 1
    if ftest == 4:
        test += 1
    else:
        test = 0
    if test == 4:
        print(str(x-3)+","+str(x-2)+","+str(x-1)+","+str(x))
        break
    if x % 100 == 0:
        print(x)
    x += 1